<template>
  <div class="newsDetails">
    <!-- 返回上一级 -->
    <el-page-header @back="goBack" content="详情页面"></el-page-header>
    <el-row :gutter="20">
      <el-col :span="17" :xs="24" style="padding: 0px">
        <div class="container">
          <div class="title">
            <h1 style="font-size: 40px">
              {{ content.noticeTitle }}
              <div class="tip">
                <div class="company"></div>
                <div class="user">
                  发布人：{{ content.createBy }}
                </div>
              </div>
              <div class="tip1">
                <div class="company"></div>
                <div class="user">
                  {{ content.createTime }}
                </div>
              </div>
            </h1>
          </div>

          <div class="img">
            <img :src="content.url" alt="" width="80%" />
          </div>
          <div class="text" style="margin-top: 40px">
            <p v-html="content.noticeContent"></p>
          </div>
        </div>
      </el-col>
      <el-col :span="1" :xs="24" style="padding: 0px">
        <el-divider direction="vertical"></el-divider>
      </el-col>
      <el-col :span="6" :xs="24" style="padding: 0px">
        <el-table v-loading="loading" :data="dataList" @row-click="newsDetails">
          <el-table-column label="通知列表" prop="noticeTitle">
            <template slot-scope="scope">
              <div class="cellClass">
                <div class="address">{{ scope.row.createTime }}</div>
                {{ scope.row.noticeTitle }}
              </div>
            </template>
          </el-table-column>
        </el-table>
        <pagination
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />
      </el-col>
    </el-row>
  </div>
</template>

<script>
import { listNotice, getNotice} from "@/api/system/notice";


export default {
  name: "Detail",
  data() {
    return {
      content: {},
      srcList: [],
      // 右侧表格数据
      dataList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      // 总条数
      total: 0,
      loading:false
    };
  },
  created() {
    this.getContent();
    this.getList();
  },
  methods: {
    /** 查询全部列表 */
    getList() {
      this.loading = true;
      listNotice(this.queryParams).then((res) => {
        if (res.code == 200) {
          this.dataList = res.rows;
          this.loading = false;
          this.total = res.total;
        }
      });
    },
    getContent() {
      /* if (this.$route.query.row) {
          this.content = JSON.parse(this.$route.query.row);
          this.srcList.push(this.content.url);
        } else {*/
      getNotice(this.$route.query.noticeId).then((res) => {
        this.content = res.data;
      });
      //this.content = JSON.parse(this.$route.query.item);
      //}
    },
    //跳转到新闻详情
    newsDetails(row) {
      this.$router.push({
        path: "/noticedetails",
        query: { noticeId: row.noticeId },
      });
    },
    // 返回上一页
    goBack() {
      this.$router.go(-1);
    },
  },
  //监听路由参数的变化刷新数据
  watch: {
    $route() {
      this.getContent();
    },
  },
};
</script>
<style lang="scss">
.newsDetails {
  padding: 20px;
  .el-divider--vertical {
    display: inline-block;
    width: 1px;
    height: 60em;
    margin: 0 8px;
    vertical-align: middle;
    position: relative;
  }
  .cellClass {
    font-weight: 700 !important;
    .cell {
      display: flex !important;
      align-items: center !important;
    }
  }
  .address {
    font-weight: 400;
    font-size: 16px;
    color: #ccc;
    text-align: left;
  }
}
.container {
  width: 80%;
  height: 100%;
  margin: 50px auto;
}

.tip {
  display: flex;
  justify-content: space-around;
  width: 100%;
  font-size: 10px;
  margin-top: 20px;
}

.tip1 {
  display: flex;
  margin-top: 20px;
  justify-content: space-around;
  width: 100%;
  font-size: 10px;
}

.title {
  margin: 50px auto;
  text-align: center;
  line-height: 40px;
}

.img {
  text-align: center;
}

.text {
  text-indent: 30px;
  math-style: 50px;
}

.content {
  margin: 20px 20px;
}

.ql-container {
  height: 250px;
}
</style>
